﻿@model TechnicBlog.Models.BrandEntity
@{
    Layout = null;
}

<script type="text/javascript">
    $(function () {
        $("#rptFireWorkList").datagrid({
            url: "FireWork/List/" + $("#BrandId").val() + "?r=" + Math.random(),
            onRowContextMenu: function (e, rowindex, rowData) {
                $("#rptFireWorkList").datagrid('selectRow', rowindex);
                e.preventDefault();
                var row = $("#rptFireWorkList").datagrid('getSelected');
                if (row) {
                    $('#menuFireWork').menu('show', {
                        left: e.pageX,
                        top: e.pageY
                    });
                }
            }

        });
    });
    function Delete() {
        var row = $("#rptFireWorkList").datagrid('getSelected');
        if (row) {
            $.messager.confirm('提醒', '<br>确定要删除<span style=\'color:#ff0000;\'>' + row.FireWorkName + '</span>这个烟花吗?', function (r) {
                if (r) {
                    form1.action = "FireWork/Delete?Id=" + row.Id;
                    alert(row.Id);
                    $('#loading').window('open');
                    $("#form1").ajaxSubmit({ action: this.action, method: this.method });
                }
            });
        } else {
            $.messager.alert('错误', '<br>请先选择要删除的数据！', 'error');
        }
    }
    function Edit() {
        var row = $("#rptFireWorkList").datagrid('getSelected');
        if (row) {
            $('#divFireWorkEdit').window({ href: 'FireWork/Edit/' + row.Id, title: '编辑烟花' }).window('open');
        } else {
            $.messager.alert('错误', '<br>请先选择要编辑的数据！', 'error');
        }
    }
    function Search() {
        $("#rptFireWorkList").datagrid({
            url: "FireWork/List/" + $("#BrandId").val() + "?FireWorkName=" + escape($.trim($("#txtFireWorkName").val())) + "&CategoryId=" + $("#CategoryId").val() + "&r=" + Math.random(),
            pageNumber: 1
        }).datagrid('reload');
    }
    function Norm() {
        var row = $("#rptFireWorkList").datagrid('getSelected');
        if (row) {
            TreeLink('Norm/Index/' + row.Id, '规格管理');
        } else {
            $.messager.alert('错误', '<br>请先选择一种烟花！', 'error');
        }
    }
    function RequestError() {
        $.messager.alert('错误', '<br>请求失败！', 'error');
    }
</script>
<form id="form1" action="FireWork/Delete" method="post" data-ajax-failure="RequestError"
data-ajax="true">
@Html.HiddenFor(model => model.Id, new { id = "BrandId" })
<div style="padding: 10px;">
    <table id="rptFireWorkList" class="easyui-datagrid" width="100%" cache="false" title="烟花列表"
        singleselect="true" toolbar="#tb" iconcls="icon-save" rownumbers="true" pagination="true"
        pagelist="[10,20,25,30]">
        <thead>
            <tr>
                <th field="Id" width="50" align="center" hidden="true">
                    Id
                </th>
                <th field="FireWorkName" width="150" align="left">
                    烟花名称
                </th>
                <th field="CategoryName" width="100" align="center">
                    品种类型
                </th>
                <th field="Material" width="100" align="center">
                    材质
                </th>
                <th field="ProductCode" width="100" align="center">
                    产品编号
                </th>
                <th field="Remark" width="250" align="left">
                    描述
                </th>
            </tr>
        </thead>
    </table>
</div>
<div id="tb" style="height: auto">
    <div style="padding: 5px; height: 26px;">
        <a href="javascript:void(0);" onclick="javascript:$('#divFireWorkEdit').window({href:'FireWork/Create/'+$('#BrandId').val(),title:'新增烟花'}).window('open');"
            class="easyui-linkbutton" style="float: left;" iconcls="icon-add" plain="true">新增</a>
        <div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0)" onclick="Edit();" class="easyui-linkbutton" style="float: left;"
            iconcls="icon-edit" plain="true">编辑</a>
        <div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0);" class="easyui-linkbutton" style="float: left;" iconcls="icon-remove"
            plain="true" onclick="javascript:Delete();">删除</a>
        <div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0);" class="easyui-linkbutton" style="float: left;" iconcls="icon-manager"
            plain="true" onclick="javascript:Norm(0);">规格管理</a>
<div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0);" class="easyui-linkbutton" style="float: left;" iconcls="icon-back"
            plain="true" onclick="javascript:TreeLink('Brand/Index', '品牌管理');">返回</a>
    </div>
    <div style="padding: 5px; height: 26px; border-top: 1px solid #CCCCCC;">
        品牌名称:<span style="color:Red;">@Html.DisplayFor(model => model.BrandName)</span>&nbsp;
        烟花名称:<input type="text" id="txtFireWorkName" />&nbsp;
        品种类型:@Html.DropDownList("CategoryId",ViewBag.CategoryList as IEnumerable<SelectListItem>)
        <a href="javascript:Search();" class="easyui-linkbutton" iconcls="icon-search">搜 索</a>
    </div>
</div>
<div id="menuFireWork" class="easyui-menu" style="width: 120px;">
    <div iconcls="icon-edit" onclick="javascript:Edit();">
        编辑</div>
    <div class="menu-sep">
    </div>
    <div iconcls="icon-remove" onclick="javascript:Delete()">
        删除</div>
    <div class="menu-sep">
    </div>
    <div iconcls="icon-manager" onclick="javascript:Norm(0)">
        规格管理</div>
</div>
<div id="divFireWorkEdit" class="easyui-window" resizable="false" title="新增烟花" minimizable="false" draggable="true"
    cache="false" modal="true" closed="true" dosize="false" collapsible="false" maximizable="false"
    style="width: 650px; height: 400px; padding-top: 10px; text-align: center;">
</div>
</form>
